<?php

namespace app\common\model;

use think\Model;

/**
 * 看守所/监狱表
 */
class Prison extends Model
{

    // 表名
    protected $name = 'detention_prison';
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    // 追加属性
    protected $append = [
    ];

    protected $dateFormat = 'Y-m-d H:i';

    protected function getMailTypeAttr($value, $data)
    {
        if (isset($data['mail_type'])) {
            return explode(',',$data['mail_type']);
        }
    }

    protected function getMailMethodAttr($value, $data)
    {
        if (isset($data['mail_method'])) {
            return explode(',',$data['mail_method']);
        }
    }

    public function province()
    {
        return $this->hasOne('app\admin\model\shopro\data\Area', 'id', 'province_id')->bind(['province_name' => 'name']);
    }

    public function city()
    {
        return $this->hasOne('app\admin\model\shopro\data\Area', 'id', 'city_id')->bind(['city_name' => 'name']);
    }

    public function area()
    {
        return $this->hasOne('app\admin\model\shopro\data\Area', 'id', 'area_id')->bind(['area_name' => 'name']);
    }
}
